import 'package:boss/ui/page/analysis/provider/analysis_provider.dart';
import 'package:boss/ui/page/analysis/widget/staff/staff_browser.dart';
import 'package:boss/ui/widget/custom_tab.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'button_group.dart';
import 'commodity/commodity_browser.dart';
import 'revenue/revenue_browser.dart';

class AnalysisBrowser extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Consumer<AnalysisProvider>(
          builder: (context, provider, child) {
            return ButtonGroup(
              margin: EdgeInsets.symmetric(
                vertical: 20.w,
                horizontal: 30.w,
              ),
              buttons: ['今日', '本周', '本月', '自定义'],
              selectedIndex: provider.timerSelectedIndex,
              height: 60.w,
              onChanged: (index) {
                provider.setTimerRange(index);
              },
            );
          },
        ),
        Expanded(
          child: CustomTab(
            tabs: ['营收', '员工', '菜品'],
            isScrollable: false,
            onChanged: Provider.of<AnalysisProvider>(context, listen: false).changeTabIndex,
            tabViews: <Widget>[
              RevenueBrowser(),
              StaffBrowser(),
              CommodityBrowser(),
            ],
          ),
        ),
      ],
    );
  }
}
